<?php
require('config.php');

        $tiezi_id=$_REQUEST['tiezi_id'];
        $content=$_REQUEST['content'];
        $dq_huifu_id=$_REQUEST['dq_huifu_id'];
        $user_id=$_REQUEST['user_id'];
        $time=date('Y-m-d H:i:s');
        if($dq_huifu_id==0 || $dq_huifu_id=="0")
        {
        	$sql="select * from `".$oto."_posts_comment` where psId='{$tiezi_id}' and status='1' and  isDel='0' order by floor DESC";
        	$result=$db->query($sql);
			while($row=$result->fetch_assoc()){
				$tiezi_lou[]=$row;//将取得的所有数据赋值给person_info数组
			}
			$max_lou=1;
			if(isset($tiezi_lou))
			{
				$max_lou=$tiezi_lou[0]['floor']+1;
			}
        	$sql="INSERT INTO ".$oto."_posts_comment (`psId`,`time`,`content`,`userId`,`pid`,`status`,`floor`,`isDel`) VALUES ('$tiezi_id','$time','$content','$user_id','0','1','$max_lou','0')";
            $result=$db->query($sql);
            if($result)
			{
				$data[0]['pan']="true";
			}
			else
			{
				$data[0]['pan']="false";
			}
			$sql="update ".$oto."_posts set `comNum`=`comNum`+1 where id='{$tiezi_id}'";
			$result=$db->query($sql);
        }
        else
        {
        	$sql="INSERT INTO ".$oto."_posts_comment (`psId`,`time`,`content`,`userId`,`pid`,`status`,`floor`,`isDel`) VALUES ('$tiezi_id','$time','$content','$user_id','{$dq_huifu_id}','1','0','0')";
            $result=$db->query($sql);
            if($result)
			{
				$data[0]['pan']="true";
			}
			else
			{
				$data[0]['pan']="false";
			}
			//$sql="update ".$oto."_posts set `dianNum`=`dianNum`+1 where id='{$tiezi_id}'";
			//$result=$db->query($sql);
        }
		echo json_encode($data);
?>